package org.lc.service.system.entity;

import java.io.Serial;
import java.io.Serializable;
import java.util.List;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.*;
import org.lc.platform.mybatis.entity.BaseEntity;
import org.lc.platform.mybatis.manager.annotation.*;

/**
 * sys_menu
 */
@EqualsAndHashCode(callSuper = true)
@Data
@TableName(autoResultMap = true)
@ToString(callSuper = true)
@OrderBy(params = {
        @Params(field = "sort", isAsc = true)
})
public class SysMenu extends BaseEntity implements Serializable {

    /**
     * 备注
     */
    private String remark;

    /**
     * 图标
     */
    private String icon;

    /**
     * 路径
     */
    private String link;

    /**
     * 遵循RESTFULL接口
     */
    private String api;

    /**
     * 名称
     */
    private String text;

    /**
     * 嵌套名称
     */
    private String frame;

    /**
     * 路由地址
     */
    private String router;

    /**
     * 文件地址
     */
    private String path;

    /**
     * 路由模式
     */
    private String moda;

    /**
     * 标题
     */
    private String title;
    /**
     * 是否缓存
     */
    private boolean keepAlive;

    /**
     * 是否显示面包屑
     */
    private boolean hideInBreadcrumb;

    /**
     * 是否禁用菜单
     */
    private Boolean forbidden;

    /**
     * 是否叶子菜单
     */
    private Boolean isLeaf;

    /**
     * 是否显示展开
     */
    private Boolean showExpand;

    /**
     * 序号
     */
    private Integer sort;

    /**
     * 主键编码
     */
    @TreeParent
    private String parentId;

    @ManyToOne(selfField = "parentId",target = SysMenu.class)
    @TableField(exist = false)
    private Parent parent;


    @OneToMany(targetField = "menuId")
    @TableField(exist = false)
    private List<SysPermission> permissions;

    @TreeChildren
    @TableField(exist = false)
    private List<SysMenu> children;

    @Serial
    private static final long serialVersionUID = 1L;

    @Data
    static class Parent {
        private String text;
    }
}